@extends('admin.layout.layout', ['row' => @$page])
@php
$deleteRight = checkMethodsAuthority('roll_delete');

@endphp

@section('contain')



<div class="portlet">
    <div class="portlet-title">
        <div class="caption">
            <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
        </div>
        <div class="actions">
            <!--<div class="item">
                    <a href="/admin/download?a=rolls_distribution&b=template" class="btn btn-primary">{{ ts('DOWNLOADDISTTEMPLATE') }}</a>
                </div>
                <div class="item">
                    <a href="/admin/rolls/importDistribution" class="btn btn-primary">{{ ts('BULKDISTIMPORT') }}</a>
                </div>-->
            {{--@if(checkMethodsAuthority('rolls_import'))
            <div class="item">
                <a href="/admin/download?a=rolls&b=template" class="btn btn-primary">{{ ts('DOWNLOADTEMPLATE') }}</a>
            </div>
            <div class="item">
                <a href="/admin/rolls/import" class="btn btn-primary">{{ ts('BULKIMPORT') }}</a>
            </div>
            @endif
            @if(checkMethodsAuthority('rolls_create') && 0)
            <div class="item">
                <a href="/{{ request()->path() }}/create" class="btn btn-primary">{{ ts('addnew') }}</a>
            </div>
            @endif--}}
        </div>
    </div>

    <div class="panel-tab">
        <a href="?t=1" class="btn {{ request()->input('t') !=2 && request()->input('t') !=3? 'btn-danger' : 'btn-primary' }} mx-3">膜卷</a>
        <a href="?t=2" class="btn {{ request()->input('t') ==2 ? 'btn-danger' : 'btn-primary' }} mx-3">套件</a>
        <a href="?t=3" class="btn {{ request()->input('t') ==3 ? 'btn-danger' : 'btn-primary' }} mx-3">套餐</a>
    </div>

    <div class="filter-wrapper">
        <form action="/{{ request()->path() }}/" class="form-inline filter-form">
            <input type="text" name="t" value="3" hidden>
            <div class=" input-group mb-3 custom-control-inline">
                <input type="text" class="form-control s-input" name="value" value="{{ request()->input('value') }}" placeholder="请输入套件ID/卷号">
            </div>

            <x-p-f-select></x-p-f-select>
{{--            <div class=" input-group mb-3 custom-control-inline">--}}
{{--                <select name="film_type_id" class="form-control filmtype_json" data-value="{{ request()->input('film_type_id') }}"></select>--}}
{{--            </div>--}}

            <div class="mb-3">
                <button class="btn btn-primary">{{ ts('SEARCH') }}</button>
                <a href="/{{ request()->path() }}/" class="btn btn-warning">{{ ts('RESET') }}</a>
            </div>
        </form>
    </div>
    <div>
        <div>
            <table class="table text-nowrap bt-table d-none text-center">
                <thead>
                <tr class="order_column text-center">
                    <th data-column="id" style="width: 80px">{{ ts('SEQUENCE') }}</th>
                    <th data-column="roll_number" style="width: 150px">{{ ts('precutid') }}</th>
                    <th data-column="film_type_id" style="width: 150px">{{ ts('part') }}</th>
                    <th>{{ ts('ylcd2') }}</th>
                    <th>{{ ts('rollnumber') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $k => $v)
                @php
                $rollNumbers = explode("\n", @$v->roll_numbers);
                @endphp
                <tr class="item-list">
                    <td>
                        {{ @$data->firstItem()+$k }}
                    </td>
                    <td>
                        {{ $v->precut_id }}
                    </td>
                    <td>
                        {{ ts('new_precut_part.'.$v->part_id) }}
                    </td>

                    <td>
                        {{ $v->length }}  cm
                    </td>
                    <td>
                        @foreach($rollNumbers as $roln)
                        <div>{{ $roln }}</div>
                        @endforeach
                    </td>
                </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="row my-3">
            <div class="col">
                {{ $data->appends(request()->input())->links() }}
            </div>
        </div>
    </div>


</div>


@endsection


@section('script')
<script>

    function getFilmTypesV2() {
        var data = coverages_data.filmtype;
        res = [];
        for (var i = 0; i < data.length; i++) {
            var o = data[i];
            if (o.value) {
                var label = o.label;
                label = String(label).toUpperCase();
                if (label.indexOf('ASP') == 0) {
                    res.push(o)
                }
            }
        }
        return res;
    }

    $(document).ready(function () {
        $('select.asp-fp').empty().append(makeSelectOptions(getFilmTypesV2(), $('select.asp-fp').data("value")));
        $('.table.bt-table').bootstrapTable({
            fixedColumns: true,
            fixedNumber: 1,
            fixedRightNumber: 1,
        }).removeClass('d-none')
    });
</script>
@endsection